<!--#include file="pj.asp"-->
<!DOCTYPE html>
<html>
<head>
<%
  vas "title", "ASP在线 ["& Easp.IIF(val("log1_id")<>"", "做题练习", "自由练习") &"] "
  easp.include "h.asp"
  'easp.db.exec "ALTER TABLE [log1] ADD [title1] NVARCHAR (100) NULL"
%>
  <style type="text/css">
      #runr_get0,#code_del,#runr,#exam_m,#code_add,#code_list,#free{
        margin-top: 10px;
      }
      #runr_get0{
        display: none;
      }
      #demo3{
        margin-bottom: 10px;
      }      
      #runr{
        height:300px;
        background-color: #F5F6F7;
      }
  </style>
  <title><%val("title")%></title>
  <script src="src/ace.js" type="text/javascript" charset="utf-8"></script>
  <script src="src/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
        <%blockquote(val("title"))%>
        <div class="layui-card">
          <div class="layui-card-body">
          <button class="layui-btn" id="demo3">
            月心编程
            <i class="layui-icon layui-icon-down layui-font-12"></i>
          </button>          
            <div class="layui-form">
              <div id="editor" style="height: 500px;"></div>
              <script>
                var editor = ace.edit("editor");
                editor.setTheme("ace/theme/solarized_light");//tomorrow_night_blue 
                editor.session.setMode("ace/mode/javascript");
                editor.setOptions({//以下部分是设置输入代码提示的
                    enableBasicAutocompletion: true,enableSnippets: true,enableLiveAutocompletion: true});
                editor.setOptions({fontSize: "15pt"});
              </script>
                <%
                  hi "getpLang","900"
                  hi "fname",val("fname")
                  hi "log1_id",val("log1_id")
                  btn0 "code_add","运行"
                  btn0 "runr_get0","查看结果"
                  btn0 "code_list","看题"
                  btn0 "exam_m","选题"  
                  btn0 "free","自由"      
                  txtarea0 "fieldn|runr,"&"value|"&val("runr")&",required::|required"
                  btn0 "code_del","清理垃圾" 
                %>
            </div>
        </div>
      </div>
  <script src="/dzps/src/layuiadmin/layui/layui.js"></script> 
  <script>
  layui.config({
    base: '/dzps/src/layuiadmin/' 
  }).extend({
    index: 'lib/index',mymod: '../../yx/js/mymod' 
  }).use(['element', 'mymod','index', 'useradmin','upload','table'], function(){
    var $ = layui.$,form = layui.form,admin = layui.admin,upload = layui.upload,table=layui.table,laypage = layui.laypage,mymod = layui.mymod,element = layui.element;

    mymod.myload("asp");
    mymod.txt_runr("runr.txt");
    form.on('submit(code_list)',function(data) {
      if($("#log1_id").val() == ''){
        mymod.msg0("当前为自由练习模式！请放飞您的思路写代码吧！",5);}
      else{
        $.post('pj.asp', {action: "code_list",log1_id1:$("#log1_id").val()},
        function(data) {
          mymod.msg0_b(data,30);
        });         
      }
    });

    form.on('submit(runr_get0)', function(data){
        let runr_original=$("#runr").val()+"\n\n";
        layer.open({
          type: 2
          , time: 2 * 1000
          , title: false
          , closeBtn: 0
          , offset: 'b'
          ,content: "upload/"+ $("#fname").val()+".asp"
          , skin: 'layui-layer-molv'
          , btn: '关闭'
          , btnAlign: 'c' //按钮居中
          , shade: 0 //不显示遮罩              
        ,success:function (layero,index) {
            tmpIndex = index;
            var body = layer.getChildFrame('#demo', index);
            
            $("#runr").val(runr_original+ body.text()+"\n\n"+"// 测试完成");
            //layer.close(index);  
            //layer.closeAll();
        },
        }); 
      $.post("upload/"+ $("#fname").val()+".asp"+'?now=' + new Date().getTime(), {
        action: "runr_get0"
      },
      function(data) {
        let runr_original=$("#runr").val()+"\n\n";
        if(data.indexOf("请检查输入文件名是否正确")!=-1){
          mymod.msg_p_runr_get0("您的代码运行中...请稍等片刻");
        }else{

        }
      });
  });
      form.on('submit(code_add)', function(data){
        var mycode=editor.getSession().getValue();
        $("#runr").val("// 运行测试");
        var field = data.field; 
				$.post('pj.asp?now=' + new Date().getTime(), {
					action: "code_add",name3:"asp",name1:"0",code:mycode,field
				},
				function(data) {
					var jsonObj = $.parseJSON(data);
					if (jsonObj.code == '0') {
						layer.msg("成功!!" + jsonObj.msg);
            $("#fname").val(jsonObj.msg);
            setTimeout(function(){ $("#runr_get0").click(); }, 3000);
					} else {layer.msg("失败！！ "+data);}
				});
    }); 
  });
  </script>
</body>
</html>